package logic

import (
	"api/pkg"
	"context"

	"api/internal/svc"
	"api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type SmsSendLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewSmsSendLogic(ctx context.Context, svcCtx *svc.ServiceContext) *SmsSendLogic {
	return &SmsSendLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *SmsSendLogic) SmsSend(req *types.SmsSendRequest) (resp *types.Response, err error) {
	err = pkg.SendSmsCode(req.Mobile, req.Source)
	if err != nil {
		return &types.Response{
			Code: 500,
			Msg:  "发送失败",
			Data: nil,
		}, nil
	}
	return &types.Response{
		Code: 200,
		Msg:  "发送成功",
		Data: nil,
	}, nil
}
